﻿using System;
using System.Linq;
using Solution.BusinessObject;
using Solution.Controls;
using Solution.Core;

namespace Solution
{
    public partial class Design : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // get language
            var language = new LanguageBO().GetLanguage(this.Language);

            // get data
            var category = CommonBO.MasterEDM.Categories
                .FirstOrDefault(t => t.Name == "Design"
                                     && t.Language.Id == language.Id);

            if (category == null)
            {
                return;
            }

            // set page title
            Page.Title = category.Title;

            rptDesigns.DataSource = CommonBO.MasterEDM.Contents
                .Where(t => t.Category.Id == category.Id &&
                            t.Enabled == true)
                .OrderByDescending(t => t.DisplayOrder)
                .ToArray();
            rptDesigns.DataBind();
        }
    }
}